
function clickButton(obj) {
	var mobile = $("#mobile").val();
    var obj = $("#checkSendOutCode");
    obj.attr("disabled", "disabled");/* 按钮倒计时 */
	if (mobile.trim().length == 0) {
		alert("请先输入手机号码");
        obj.attr("disabled", false).val("发送验证码");/* 倒计时 */
		$("#mobile").focus();
		return false;
	}
	if(!(/^1[34578]\d{9}$/.test(mobile.trim()))){
        alert("请输入正确的手机号");
        obj.attr("disabled", false).val("发送验证码");/* 倒计时 */
        return false;
    }
	
    $.ajax({
        type:"POST",
        url:"../auth/getLoginValidCode",
        data:{mobile:mobile},
        dataType:"json",
        success:function(result){
        	alert(result.msg);
            if(result.code==0){
                getValidCode();
            }else{
                obj.attr("disabled", false).val("发送验证码");/* 倒计时 */
            }
        },error: function (data) {
            obj.attr("disabled", false).val("发送验证码");/* 倒计时 */
        }
    });
}

function getValidCode(){
    var obj = $("#checkSendOutCode");
    var time = 60;
    var set = setInterval(function() {
        obj.val(--time + "(s)");
    }, 1000);/* 等待时间 */
    setTimeout(function() {
        obj.attr("disabled", false).val("重新获取验证码");/* 倒计时 */
        clearInterval(set);
    }, 60000);
}